package com.qf.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 解决跨域问题
 */
@Configuration
public class CrossConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")  // 匹配所有路径
                .allowedOriginPatterns("*")// 允许所有的域访问
                .allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS") // 允许所有的方法
                .allowCredentials(true)
                .maxAge(3600)
                .allowedHeaders("*");
    }
}
